package com.joker.demo.core.config;

import java.io.Serializable;

/**
 * 任务执行器配置
 *
 * @author : feixiang.li
 * @since : 2025-07-24 13:46
 */
public class JobExecutorProperties implements Serializable {


    /**
     * 任务执行器端口（并非服务端的端口，服务端的端口信息需要拼接在adminUrl中）
     */
    private Integer port = 9999;


    private Integer serverPort = 8080;

    /**
     * 调度器地址
     */
    private String serverUrl = "http://localhost";

    /**
     * 访问令牌
     */
    private String accessToken = "";

    /**
     * 应用名称
     */
    private String groupName = "spring-boot-executor";

    /**
     * 线程池监控配置
     */
    private ThreadPoolMonitorConfig threadPoolMonitor = new ThreadPoolMonitorConfig();

    @Override
    public String toString() {
        return "JobExecutorProperties{" +
                "port=" + port +
                ", serverPort=" + serverPort +
                ", serverUrl='" + serverUrl + '\'' +
                ", accessToken='" + accessToken + '\'' +
                ", groupName='" + groupName + '\'' +
                ", threadPoolMonitor=" + threadPoolMonitor +
                '}';
    }

    public Integer getServerPort() {
        return serverPort;
    }

    public void setServerPort(Integer serverPort) {
        this.serverPort = serverPort;
    }

    public String getGroupName() {
        return groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }

    public String getAccessToken() {
        return accessToken;
    }

    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }

    public String getServerUrl() {
        return serverUrl;
    }

    public void setServerUrl(String serverUrl) {
        this.serverUrl = serverUrl;
    }

    public Integer getPort() {
        return port;
    }

    public void setPort(Integer port) {
        this.port = port;
    }

    public ThreadPoolMonitorConfig getThreadPoolMonitor() {
        return threadPoolMonitor;
    }

    public void setThreadPoolMonitor(ThreadPoolMonitorConfig threadPoolMonitor) {
        this.threadPoolMonitor = threadPoolMonitor;
    }

    /**
     * 线程池监控配置
     */
    public static class ThreadPoolMonitorConfig implements Serializable {
        
        /**
         * 是否启用线程池监控
         */
        private boolean enabled = true;
        
        /**
         * 监控数据发送间隔（秒）
         */
        private int intervalSeconds = 10;
        
        /**
         * 是否监控线程堆栈信息
         */
        private boolean monitorThreadStack = true;
        
        /**
         * 是否监控内存使用情况
         */
        private boolean monitorMemory = true;

        public boolean isEnabled() {
            return enabled;
        }

        public void setEnabled(boolean enabled) {
            this.enabled = enabled;
        }

        public int getIntervalSeconds() {
            return intervalSeconds;
        }

        public void setIntervalSeconds(int intervalSeconds) {
            this.intervalSeconds = intervalSeconds;
        }

        public boolean isMonitorThreadStack() {
            return monitorThreadStack;
        }

        public void setMonitorThreadStack(boolean monitorThreadStack) {
            this.monitorThreadStack = monitorThreadStack;
        }

        public boolean isMonitorMemory() {
            return monitorMemory;
        }

        public void setMonitorMemory(boolean monitorMemory) {
            this.monitorMemory = monitorMemory;
        }

        @Override
        public String toString() {
            return "ThreadPoolMonitorConfig{" +
                    "enabled=" + enabled +
                    ", intervalSeconds=" + intervalSeconds +
                    ", monitorThreadStack=" + monitorThreadStack +
                    ", monitorMemory=" + monitorMemory +
                    '}';
        }
    }
}